<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Parent Page</title>
    <script src="http://libs.baidu.com/jquery/1.9.0/jquery.js"></script>
    <meta charset="utf-8">
    <title>Bootstrap 实例 - 倒置的导航栏</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
    <script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
    <script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>

    <script language="javascript" type="text/javascript">
        function uploadFile() {
            var file = $("#upload").val();
            file = file.substring(file.lastIndexOf('.'), file.length);
            if (file == '') {
                alert("上传文件不能为空！");
            } else if (file != '.xlsx' && file != '.xls') {
                alert("请选择正确的excel类型文件！");
            } else {
                ajaxFileUpload();
            }
        }

        function ajaxFileUpload() {

            var formData = new FormData();
            var name = $("#upload").val();
            formData.append("file", $("#upload")[0].files[0]);
            formData.append("name", name);
            $.ajax({
                url: "excel/InputExcel.do",
                type: "POST",
                async: false,
                data: formData,
                processData: false,
                contentType: false,
                beforeSend: function () {
                    console.log("正在进行，请稍候");
                },
                success: function (e) {
                    if (e == "01") {
                        alert("导入成功");
                    } else {
                        alert("导入失败");
                    }
                }
            });
        }

        function OutputExce() {
            window.location.href = "/ExcelDemo/excel/OutputExcel.do";
        }
    </script>


</head>
<body>
<div style="width:100%; height:5%;background-color: aqua;">
    <nav class="navbar navbar-inverse" role="navigation">
        <div class="container-fluid">
            <div>
                <ul class="nav navbar-nav">
                    <li>
                        <a href="#">跳转</a>
                    </li>
                    <li class="active">
                        <a href="#" id="child1" value="" onclick="btnClick1()">子页面1</a>
                    </li>
                    <li>
                        <a href="#" id="child2" value="" onclick="btnClick2()">子页面2</a>
                    </li>
                    <li>
                        <a href="#" id="child3" value="" onclick="btnClick3()">百度</a>
                    </li>
                    <li class="dropdown">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                            Java <b class="caret"></b>
                        </a>
                        <ul class="dropdown-menu">
                            <li><a href="#">jmeter</a></li>
                            <li><a href="#">EJB</a></li>
                            <li><a href="#">Jasper Report</a></li>
                            <li class="divider"></li>
                            <li><a href="#">分离的链接</a></li>
                            <li class="divider"></li>
                            <li><a href="#">另一个分离的链接</a></li>
                        </ul>
                    </li>
                </ul>
            </div>
        </div>
    </nav>
</div>
<table>
    <tr>
        <td><input type="file" id="upload" name="upload" value=""/></td>
        <td>
            <button onclick="uploadFile()">上传</button>
        </td>
        <td>
            <button onclick="OutputExce()">导出</button>
        </td>
    </tr>
</table>


</body>
</html>
